﻿ function defaultFunction(){
 var index=0;
 $("input,select,textarea").each(function(){
  
 $(this).attr("tabIndex",++index);
 });
 $("input[type='button']").bind("keypress",function(e){
 var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
 if(key==13){
 $(this).click();
 return false;
 }
 });
$("input").enter2tab();
$("select").enter2tab();
$("textarea").enter2tab();
	$("ul[class='menu'] a[url]").click(function(){
		try{
			$("div[class='form']").dialog('destroy').remove();
			}catch(e){
				}
	var url=$(this).attr("url");
	 $("div[id='loadData']").load(url);
	
	});
	var height=$("div[class='frame']").height();
	 
	$("div#divFrame").height("100%");
	$("div[class='links']").height(height-32-35);
	$("div#loadData").css("overflow","auto");
	$("div#divFrame").addClass("ui-widget-content");
	 $("ul[class='menu'] ").hide();
	 $("ul[class='menu']:first").show();
 $("ul[class='menu']").menu();
 //$("ul[class='menu'] li").hide()
  
$("td[linkHeader] img").click(function(){
	   var index=$(this).index();							  
$("div[class='links'] table td:nth-child(2) img").removeClass("ui-button ui-widget ui-state-active ui-corner-all");
 $("div[class='links'] table td:nth-child(2) img").addClass("ui-button ui-widget ui-state-default ui-corner-all");
 $(this).addClass("ui-button ui-widget ui-state-active ui-corner-all");
									   $("div[class='links'] table td:nth-child(2) img").css("width","24px");
									   $(this).css("width","32px");
									   $(this).effect("slide");
								
									    $("ul[linkIndex]").hide();
										 var key="ul[linkIndex="+index+"]";
										 $(key).slideDown();
									 
									   
									   
									   });
$("input[data]").each(function(){
	$(this).width($(this).width()-20);
	$(this).datepicker();
	
});
  
  
	} 

 jQuery.fn.enter2tab = function()
{
    this.keypress(function(e){
        // get key pressed (charCode from Mozilla/Firefox and Opera / keyCode in IE)
        var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
         
        var tmp = null;
        var maxTabIndex = 96;
         
        // get tabindex from which element keypressed
        var nTabIndex=this.tabIndex+1;
         
        // get element type (text or select)
        var myNode=this.nodeName.toLowerCase();
         
        // allow enter/return key (only when in an input box or select)
        if(nTabIndex > 0 && key == 13 && nTabIndex <= maxTabIndex && ((myNode == "textarea") || (myNode == "input") || (myNode == "select") || (myNode == "a")))
        {
            for (var x=0; x<3; x++)
            {
                tmp = $("a[tabIndex='"+nTabIndex+"'],textarea[tabIndex='"+nTabIndex+"'],select[tabIndex='"+nTabIndex+"'],input[tabIndex='"+nTabIndex+"']").get(0);
                if (typeof tmp != "undefined" && !$(tmp).attr("disabled"))
                {
                    $(tmp).focus();
                    return false;
                    //break;
                }
                else
                {
                    nTabIndex++;
                }
            }
            return false;
        }
        else if(key == 13)
        {
            return false;
        }
    })
    return this;
}